{include file="public/header" /}
<body>
<style>
    .cion{
        display: inline-block;
        width: 120px;
    }
</style>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 文章管理
    <span class="c-gray en">&gt;</span> 文章列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <form  method="get" action="">
        <div class="text-c">
            <input type="text" class="input-text" style="width:250px" placeholder="文章标题" value="{:input('title')}" name="title">
            <span class="select-box" style="width: 100px;">
                <select name="type" class="select">
                    <option value="0">全部类型</option>
                    {foreach $types as $v}
                        {if $v.id ==:input('type')}
                        <option value="{$v.id}" selected>{$v.title}</option>
                        {else/}
                        <option value="{$v.id}">{$v.title}</option>
                        {/if}
                    {/foreach}
                </select>
            </span>
            <button type="submit" class="btn btn-success">搜索</button>
        </div>
    </form>
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="javascript:;" onclick="layopen('添加文章','{:url('edit')}',900,650)" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加文章</a>
        </span>
        <span class="r">共有数据：<strong>{$list->total()}</strong> 条</span> </div>
    <table class="table table-border table-bordered table-hover table-bg">
        <thead>
        <tr>
            <th scope="col" colspan="9">文章列表</th>
        </tr>
        <tr class="text-c">
            <th width="70">标识</th>
            <th width="100">文章标题</th>
            <th width="100">文章类型</th>
            <th width="80">文章说明</th>
            <th width="100">状态操作</th>
            <th width="50">操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $list as $v}
        <tr class="text-c">
            <td class="text-l">
                {$v.id}
            </td>
            <td class="text-l">
                {$v.title}
            </td>
            <td class="text-l">
                {$v.type_name}
            </td>
            <td class="text-l">
                {$v.introduce}
            </td>
            <td>
                {if $v.status == 1}
                <span class="label label-success radius" onclick="article_start(this,{$v.id},{$v.status})">
                        已启用</span>
                {else/}
                <span class="label label-danger radius" onclick="article_start(this,{$v.id},{$v.status})">
                        禁用中</span>
                {/if}
            </td>
            <td>
                <a class="btn btn-default radius" title="个人信息" href="javascript:;" onclick="layopen('文章编辑','{:url('edit',['id'=>$v.id])}',900,650)"><i class="Hui-iconfont">&#xe6df;</i></a>
            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>
    <div class="page">
        {$list->render()|raw}
    </div>
</div>

{include file="public/footer" /}

<script type="text/javascript">
    function article_start(obj,id,status){
        if(status == 1){
            var info = '确认要禁用吗？';
        }else{
            var info = '确认要启用吗？';
        }
        layer.confirm(info,function(index){
            $.ajax({
                type: 'POST',
                url: "{:url('status')}",
                data: {id:id,status:status},
                dataType: 'json',
                success: function(data){
                    if(data.status == 'y'){
                        layer.msg("操作成功",{icon:1,time:1000,shade: [0.3, '#000']},function(){
                            location.replace(location.href);
                        });
                    }else{
                        layer.msg(data.info,{icon:2,time:1000,shade: [0.3, '#000']});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }
    function profit_start(obj,id,profit_status){
        if(profit_status == 1){
            var info = '确认禁止发放矿机收益吗？';
        }else{
            var info = '确认开启发放矿机收益吗？';
        }
        layer.confirm(info,function(index){
            $.ajax({
                type: 'POST',
                url: "{:url('profit_status')}",
                data: {id:id,status:profit_status},
                dataType: 'json',
                success: function(data){
                    if(data.status == 'y'){
                        layer.msg("操作成功",{icon:1,time:1000,shade: [0.3, '#000']},function(){
                            location.replace(location.href);
                        });
                    }else{
                        layer.msg(data.info,{icon:2,time:1000,shade: [0.3, '#000']});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }
    function auth(obj,id,status,field){
        if(status == 0){
            var info = '确认要启用吗？';
        }else{
            var info = '确认要禁用吗？';
        }
        layer.confirm(info,function(index){
            $.ajax({
                type: 'POST',
                url: "{:url('auth')}",
                data: {id:id,status:status,field:field},
                dataType: 'json',
                success: function(data){
                    if(data.status == 'y'){
                        layer.msg("操作成功",{icon:1,time:1000,shade: [0.3, '#000']},function(){
                            location.replace(location.href);
                        });
                    }else{
                        layer.msg(data.info,{icon:2,time:1000,shade: [0.3, '#000']});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }

</script>